package com.jinyi.wwdeng.ui.config.adapter

import android.graphics.Typeface
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import cn.bingoogolapple.baseadapter.BGARecyclerViewAdapter
import cn.bingoogolapple.baseadapter.BGAViewHolderHelper
import com.jinyi.wwdeng.R
import org.json.JSONObject

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/18 10:43
 * @Annotation：资料配置Tab适配器
 */
class ConfigTabAdapter(recyclerView: RecyclerView?) :
    BGARecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_config_tab) {

    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        val isSelect = model.optBoolean("isSelect", false)
        var tvTitle = helper.getTextView(R.id.tvTitle)
        var vCursor = helper.getView<View>(R.id.vCursor)
        tvTitle.text = mContext.getString(model.optInt("tabTitle"))

        if (isSelect) {
            tvTitle.setTypeface(Typeface.DEFAULT,Typeface.BOLD)
            tvTitle.setTextColor(ContextCompat.getColor(mContext, com.jinyi.lib_base.R.color.color_000000))
            vCursor.visibility = View.VISIBLE
        } else {
            tvTitle.setTypeface(Typeface.DEFAULT,Typeface.NORMAL)
            tvTitle.setTextColor(ContextCompat.getColor(mContext, R.color.color_767676))
            vCursor.visibility = View.INVISIBLE
        }
    }
}